var openalllinks = {
  onMenuItemCommand: function(e) {
    var msgPane = document.getElementById("messagepane");
    
    if ( msgPane )
    {
        var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
        var branch = prefs.getBranch("extensions.openalllinks.");

        var exclude = false;
        var confirm = true;

        if ( branch.getPrefType("exclude") == prefs.PREF_STRING ) {
            exclude = new RegExp( branch.getCharPref("exclude"), "gi" );
        }

        if ( branch.getPrefType("confirm") == prefs.PREF_BOOL ) {
            confirm = branch.getBoolPref("confirm");
        }

        var anchors = msgPane.contentDocument.getElementsByTagName("a");
        var href;

        for ( var i = 0; i < anchors.length; i++ )
        {
            href = anchors[i].href;
            if ( href.substring(0,7) == 'http://' || href.substring(0,8) == 'https://' ) {
                if ( exclude ) {
                    if ( exclude.test( href ) ) {
                        continue;
                    }
                }

                messenger.launchExternalURL( href );
            }
        }
    }
  }
};